package com.topfox.common;

public class CommonException extends TopException{
    public CommonException(String code, String msg) {
        super(code, msg);
    }

    public CommonException(ResponseCode responseCode){
        super(responseCode);
    }

    public CommonException(ResponseCode responseCode, String msg){
        super(responseCode,msg);
    }

    public static CommonException newInstance2(ResponseCode responseCode){
        ExceptionBuilder exceptionBuilder= create(responseCode.getCode(),null);//new CommonString(responseCode.getCode(),null);
        exceptionBuilder.getMsg().append(responseCode.getMsg());
        return new CommonException(responseCode, exceptionBuilder.getMsg().toString());
    }

    public static ExceptionBuilder newInstance(ResponseCode responseCode){
        return create(responseCode.getCode(), null);
    }
    public static ExceptionBuilder newInstance(String responseCode){
        return create(responseCode, null);
    }

    private static ExceptionBuilder create(String responseCode, Object target){
        return new ExceptionBuilder(CommonException.class,responseCode, target);
    }
}
